package com.todolist.server.service;

import com.todolist.client.service.TaskService;
import com.todolist.server.persistence.TaskMapper;
import com.todolist.shared.domain.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service("taskService")
public class TaskServiceImpl implements TaskService {

    @Autowired
    private TaskMapper taskMapper;

    @Override
    public Task getTask(String text) {
        return null;
    }

    @Override
    public void addTask(Integer projectId, String text, Integer priority) {
        taskMapper.addTask(projectId, text, priority);
    }

    @Override
    public void updateTaskText(String oldText, String newText) {
        taskMapper.updateTaskText(oldText, newText);
    }

    @Override
    public void updateTaskCompleteness(String text, Boolean completed) {
        taskMapper.updateTaskCompleteness(text, completed);
    }

    @Override
    public void updateTaskPriority(String text, Integer priority) {
        taskMapper.updateTaskPriority(text, priority);
    }

    @Override
    public void deleteTask(Integer projectId, String text) {
        taskMapper.deleteTask(projectId, text);
    }

    @Override
    public void deleteTasks(Integer projectId) {
        taskMapper.deleteTasks(projectId);
    }

    @Override
    public ArrayList<Task> getTasks(Integer projectId) {
        return taskMapper.getTasks(projectId);
    }

    public Integer getMaxTaskPriority() {
        return taskMapper.getMaxTaskPriority();
    }
}
